#include "scene.h"
#include "jsonUtils.h"

void Scene::fromJson(const JsonValue& value)
{
	JsonUtils::loadLong(value, L"id", id);
	JsonUtils::loadInt(value, L"sequence", sequence);
	JsonUtils::loadStr(value, L"name", name);
	JsonUtils::loadStr(value, L"file", file);
	JsonUtils::loadInt(value, L"playMode", playMode);
}

void Scene::toJson(JsonValue& value, JsonDoc::AllocatorType& allocator, bool toConfig /*= false*/) const
{
	value.AddMember(L"sequence", sequence, allocator);
	JsonUtils::addString(value, L"name", name, allocator);
	value.AddMember(L"playMode", playMode, allocator);
	if (toConfig) {
		value.AddMember(L"id", id, allocator);
		JsonUtils::addString(value, L"file", file,allocator);
	}
}

const int& Scene::getSequence() const
{
	return sequence;
}

const String& Scene::getFilePath() const
{
	return file;
}

const int64_t& Scene::getId()
{
	return id;
}

const String& Scene::getName() const
{
	return name;
}

bool Scene::autoNext() const
{
	return playMode == 2;
}

bool Scene::cyclePlay() const
{
	return playMode == 1 || playMode == 4;
}
